package exteditapp.state;

import exteditapp.AppletIterator;
import exteditapp.FileDefault;
import exteditapp.action.ActionEditingManual;

/**
 * State - edit (shows when was last modification)
 * @author Arturas Smorgn, arturas@smorgun.lt
 */
public class StateEditingManual extends IState {

	String label1 = "AUTOSAVE IS DISABLED";
	String label2 = "PRESS TO SAVE MANUALLY";
	
	/**
	 * Default constructor
	 * @param iterator is system iterator, which performs all actions
	 * @param file this is file, which state we will hold
	 */
	public StateEditingManual(AppletIterator iterator, FileDefault file) {
		super(iterator, file);
		start();
	}
	public StateEditingManual(AppletIterator iterator, FileDefault file, boolean doRegister){
		super(iterator, file, doRegister);
		start();
	}
	
	protected void start(){
		this.setAction(new ActionEditingManual());
		//determine time of last save
		if(file.getFileAsObject().lastModified() != file.getLastModified()){
			file.setLastModified(file.getFileAsObject().lastModified());
		}
		//TODO implement start of state
	}
	
	/**
	 * Handling of new state
	 */
	public boolean handle() {
		//TODO implement edit state handling
		if(this.getLifetime() % 4 == 0)
			this.label = label1;
		else if((this.getLifetime()+2) % 4 == 0)
			this.label = label2;
		return false;
	}
	
}
